/* 
 * File:   MPIBasics.h
 * Author: alexander
 *
 * Created on July 28, 2011, 3:17 PM
 */

#ifndef MPIBASICS_H
#define	MPIBASICS_H

#include <stdio.h>
#include <mpi.h>

class MPIBasics {
public:
    
    static const bool DEBUG_MASTER = false;
    static const bool DEBUG_SLAVE = false;
    
    
    //TAGS
    static const int TAG_SLAVE_FINAL_SOLUTION = 100;
    static const int TAG_WAIT_NEW_SOLUTION = 101;
    static const int TAG_BEST_SOLUTION = 102;
    static const int TAG_BEST_H = 103;
    static const int TAG_RESTART_GRASP = 104;
    static const int TAG_FNEVALS_TOTAL = 105;
    static const int TAG_CURRENT_H = 106;
    static const int TAG_FINALIZE_SLAVE = 107;
    //END OF TAGS
    
    static void sendSolution(double *s, int n, int dest, int tag);
    static void receiveSolution(double *x, int n, int source, int tag, MPI_Status *status);
    static void sendDouble(double *value, int n, int dest, int tag);
    static void receiveDouble(double *value, int n, int source, int tag, MPI_Status *status);
    static void sendInteger(int *value, int n, int dest, int tag);
    static void receiveInteger(int *value, int n, int source, int tag, MPI_Status *status);
    static void ping();
private:
    MPIBasics();
    MPIBasics(const MPIBasics& orig);
    virtual ~MPIBasics();

};

#endif	/* MPIBASICS_H */

